import turtle
from tkinter import *
from tkinter.scrolledtext import ScrolledText
def snake():
	turtle.speed(0)
	turtle.setup(650,350,200,200)
	turtle.penup()
	turtle.fd(-250)
	turtle.pendown()
	#搞一个tkinter，两个输入框，加上随机和默认功能，参考浏览器.py
	turtle.pensize(snakesize.get())
	turtle.pencolor(snakecolor.get())
	turtle.seth(-40)
	for i in range(4):
		turtle.circle(40,80)
		turtle.circle(-40,80)
	turtle.circle(40,40)
	turtle.fd(40)
	turtle.circle(16,180)
	turtle.fd(40*2/3)
	turtle.hideturtle()
	turtle.done()
def snake2():
	turtle.speed(0)
	turtle.setup(650,350,200,200)
	turtle.penup()
	turtle.fd(-250)
	turtle.pendown()
	#搞一个tkinter，两个输入框，加上随机和默认功能，参考浏览器.py
	turtle.pensize(25)
	turtle.pencolor("green")
	turtle.seth(-40)
	for i in range(4):
		turtle.circle(40,80)
		turtle.circle(-40,80)
	turtle.circle(40,40)
	turtle.fd(40)
	turtle.circle(16,180)
	turtle.fd(40*2/3)
	turtle.hideturtle()
	turtle.done()
def snake_random():
	from random import randint,choice
	turtle.speed(0)
	turtle.setup(650,350,200,200)
	turtle.penup()
	turtle.fd(-250)
	turtle.pendown()
	#搞一个tkinter，两个输入框，加上随机和默认功能，参考浏览器.py
	turtle.pensize(randint(10,20))
	turtle.pencolor(choice(['red','orange','yellow','green','cyan','blue','purple','gold']))
	turtle.seth(-40)
	for i in range(4):
		turtle.circle(40,80)
		turtle.circle(-40,80)
	turtle.circle(40,40)
	turtle.fd(40)
	turtle.circle(16,180)
	turtle.fd(40*2/3)
	turtle.hideturtle()
	turtle.done()
top=Tk()
top.title("蟒蛇")
top.geometry('850x25')
label = Label(text='请输入颜色（英文）：')
label.pack(side=LEFT)
c=ScrolledText()
snakecolor=Entry()
snakesize=Entry()
snakecolor.pack(side=LEFT,expand=True,fill=BOTH)
label = Label(text='请输入大小（数字）：')
label.pack(side=LEFT)
snakesize.pack(side=LEFT,expand=True,fill=BOTH)
Button(text='显示',command=snake).pack(side=RIGHT)
Button(text='显示默认',command=snake2).pack(side=RIGHT)
Button(text='显示随机',command=snake_random).pack(side=RIGHT)
label = Label(text='显示蟒蛇后应退出重进！！！')
label.pack(side=RIGHT)
mainloop()